#CAM用户组不为空
resource "tencentcloud_cam_group_membership" "foo" {
  group_id   = tencentcloud_cam_group.foo.id
  user_names = [tencentcloud_cam_user.foo.name, tencentcloud_cam_user.bar.name]
}

#授权给CAM用户
resource "tencentcloud_cam_user_policy_attachment" "foo" {
  user_id   = tencentcloud_cam_user.foo.id
  policy_id = tencentcloud_cam_policy.foo.id
}

#不存在超级管理员
resource "tencentcloud_cam_policy" "foo" {
  name        = "cam-policy-test"
  document    = <<EOF
{
  "version": "2.0",
  "statement": [
    {
      "action": [
        "name/sts:AssumeRole"
      ],
      "effect": "allow",
      "resource": [
        "*"
      ]
    }
  ]
}
EOF
  description = "test"
}

#CAM用户密码策略符合要求 
resource "tencentcloud_cam_user" "foo" {
  name                = "cam-user-testfoo"
  remark              = "test"
  console_login       = true
  use_api             = true
  need_reset_password = true
  password            = "Gail@1234"
  phone_num           = "12345678910"
  email               = "hello@test.com"
  country_code        = "86"
  force_delete        = true
}
#CAM用户归属用户组
resource "tencentcloud_cam_user" "bar" {
  name                = "cam-user-testbar"
  remark              = "test"
  console_login       = true
  use_api             = true
  need_reset_password = true
  password            = "Gail@1234"
  phone_num           = "12345678910"
  email               = "hello@test.com"
  country_code        = "86"
  force_delete        = true
}

#MySQL
#实例备份保留天数有效值
resource "tencentcloud_mysql_backup_policy" "default" {
  mysql_id         = "cdb-dnqksd9f"
  retention_period = 7
  backup_model     = "physical"
  backup_time      = "02:00-06:00"
}

#公共访问端口。有效值范围：[1024~65535]
resource "tencentcloud_mysql_instance" "default" {
  internet_service  = 1
  engine_version    = "5.7"
  charge_type       = "POSTPAID"
  root_password     = "********"
  slave_deploy_mode = 0
  first_slave_zone  = "ap-guangzhou-4"
  second_slave_zone = "ap-guangzhou-4"
  slave_sync_mode   = 1
  availability_zone = "ap-guangzhou-4"
  project_id        = 201901010001
  instance_name     = "myTestMysql"
  mem_size          = 128000
  volume_size       = 250
  vpc_id            = "vpc-12mt3l31"
  subnet_id         = "subnet-9uivyb1g"
  intranet_port     = 3306
  security_groups   = ["sg-ot8eclwz"]

  tags = {
    name = "test"
  }

  parameters = {
    max_connections = "1000"
  }
}

#云文件存储访问组长度合法
resource "tencentcloud_cfs_access_group" "foo" {
  name        = "test_access_group"
  description = "test"
}
 
#云文件存储priorit有效范围合法 读写权限合法 用户访问权限user_permission合法
resource "tencentcloud_cfs_access_rule" "foo" {
  access_group_id = "pgroup-7nx89k7l"
  auth_client_ip  = "10.10.1.0/24"
  priority        = 1
  rw_permission   = "RO"
  user_permission = "root_squash"
}
#云文件存储 文件服务存储类型
resource "tencentcloud_cfs_file_system" "foo" {
  name              = "test_file_system"
  availability_zone = "ap-guangzhou-3"
  access_group_id   = "pgroup-7nx89k7l"
  protocol          = "NFS"
  vpc_id            = "vpc-ah9fbkap"
  subnet_id         = "subnet-9mu2t9iw"
}